#ifndef __BSP_SERIAL_H
#define __BSP_SERIAL_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "bsp_Inc.h"
#include <string.h>

#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
#include "tool_Fifo.h"
class bsp_Serial:public tool_Fifo
{
private:
#define SERIAL_TIMEOUT 100
#define SERIAL_BUFFER_LEN 256
    typedef enum
    {
        SERIAL_OK = 0U,
        SERIAL_ERROR = 1U,
    } Serial_ret;
    BSP_UART_Handle_t *huart;

public:
    QUEUE_DATA_T rxTemp;
    QUEUE_DATA_T rxBuffer[SERIAL_BUFFER_LEN];

    bsp_Serial(BSP_UART_Handle_t *huartx) : tool_Fifo(rxBuffer, SERIAL_BUFFER_LEN)
    {
        huart = huartx;
    }
    ~bsp_Serial()
    {
    }
    void init();
    Serial_ret send(const char *buffer, int size);
    Serial_ret receive(char *buffer, int size, int timeout);
    void rxCallback();
};

#if DEMO_SERIAL
extern bsp_Serial demoSerial;
#endif

#endif

#endif
